package cn.bluedot.bean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;

public class DataBaseBody extends BaseBody{
    private Map<String, Object> extend = new HashMap<String, Object>();
    
    public static final String tableData = "data";
    
    protected DataBaseBody(int code, String msg) {
        super(code, msg);
        
    }
    
    public Map<String, Object> getExtend() {
        return extend;
    }

    public void setExtend(Map<String, Object> extend) {
        this.extend = extend;
    }
    
    public BaseBody add(String key,Object value){
        this.getExtend().put(key, value);
        return this;
    }
    
    public static DataBaseBody getFailDataBody() {
        DataBaseBody dbb = new DataBaseBody(FAIL.getCode(), FAIL.getMsg());
        return dbb;
    }
    
    public static DataBaseBody getSuccessDataBody() {
        DataBaseBody dbb = new DataBaseBody(SUCCESS.getCode(), SUCCESS.getMsg());
        return dbb;
    }
    
    public static <T> DataBaseBody getSuccessDataBody(PageBean<T> data) {

        DataBaseBody dbb = new DataBaseBody(SUCCESS.getCode(), SUCCESS.getMsg());
        dbb.add(DataBaseBody.tableData, data);
        return dbb;
    }
}
